Skip to content

Let LongBridge sell BOXX when buying power is short#65

Merged
Pigbibi merged 3 commits into
mainfrom
codex/longbridge-cash-sweep-fallback
May 16, 2026
Merged

Let LongBridge sell BOXX when buying power is short#65
Pigbibi merged 3 commits into
mainfrom
codex/longbridge-cash-sweep-fallback

Conversation

@Pigbibi
Copy link
Copy Markdown
Collaborator

@Pigbibi Pigbibi commented May 16, 2026

Adjust the LongBridge execution flow so the cash-sweep symbol can be sold even when the underweight candidate is smaller than one share and buying power is short.

This keeps the platform from getting stuck holding BOXX when the strategy wants to move into SOXL/SOXX but only a partial position can be funded on the current run.

Tests:

  • PYTHONPATH=/home/ubuntu/Projects/QuantPlatformKit/src:/home/ubuntu/Projects/UsEquityStrategies/src python3 -m pytest tests/test_rebalance_service.py -k cash_sweep -q
  • python3 -m py_compile application/execution_service.py tests/test_rebalance_service.py

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 59f8630aaa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +540 to +541
if sweep_quantity <= 0:
sweep_quantity = 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not force BOXX sale when funding need is zero

When cash_sweep_sale_quantity_to_fund_buy(...) returns 0 (for example, because current investable cash already covers the next buy), this branch overwrites it to 1 and still submits a BOXX sell. In execute_rebalance_cycle, that means any cycle with a buy candidate and sellable BOXX can generate an unnecessary market sell even though no additional funding is needed, causing avoidable churn and allocation drift.

Useful? React with 👍 / 👎.

@Pigbibi Pigbibi merged commit 4656875 into main May 16, 2026
1 check passed
@Pigbibi Pigbibi deleted the codex/longbridge-cash-sweep-fallback branch May 16, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant